-
Notifications
You must be signed in to change notification settings - Fork 199
Improve ARM architecture detection: arm64 and armv7 #106
Conversation
if (unameOut.includes('armv7')) return 'armv7'; | ||
return ''; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was only after writing and testing the code that I realised that there is already an open PR on the same topic: #101
I'd say that this PR (#106) is a bit more robust / conservative and complete, because:
- It falls back to the existing
/proc/cpuinfo
implementation ifuname
is not available (however unlikely). Note thatspawnSync('uname', ['-a'])
does not throw an Error ifuname
does not exist, but setsuname.error
which the code detects. uname -a
is a bit more robust thanuname -m
(thinking of all different Unix kernels out there: BSD, Solaris, Linux, even perhaps macOS...), as it does not rely on a particular field or implementation ofuname
.- The detection is case insensitive.
- It detects
arm64
(e.g. Raspberry Pi 4) in addition toarmv7
(e.g. Raspberry Pi 2/3). I've tested on both!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close this PR so :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok sorry I misunderstood the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pdcastro I really appreciate your help here and the descriptive comment!
I don’t think they will answer
|
@leerob please consider merging this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much! We appreciate your contribution back. I will try my best to help review / merge PRs that haven't been looked at in awhile.
When running
pkg
in a Docker Desktop ARM-image container on an Intel laptop, usingbinfmt_misc
/ QEMU architecture emulation,/proc/cpuinfo
reports the Intel processor rather than the emulated ARM processor. The existing architecture detection then fails. Also, the existing detection code does not support arm64 (e.g. the Raspberry Pi 4), reportingarmv6
instead.